# coding: UTF-8

import urllib

class JsMap:
    

    def __init__(self, appid):
        self.appid = appid
        self.url = 'http://js.api.olp.yahooapis.jp/OpenLocalPlatform/V1/jsapi'
        self.params = {}
        self.params['appid'] = self.appid
        self.pins = {}

    def jsapi (self):
        return self.url + '?appid=' + self.params['appid']

    def script(self):
        return '<script type="text/javascript" charset="utf-8" src="' + self.url() + '"></script>'



    def lat(self, lat):
        self.params['lat'] = lat
        return self
    
    def lon(self, lon):
        self.params['lon'] = lon
        return self

    def z(self, z):
        self.params['z'] = z
        return self

    def datum(self, datum):
        self.params['datum'] = datum
        return self

    def pin(self, lat, lon, index='', label='', color=''):
        pin = "pin%s"%(index)
        self.params[pin] = "%s,%s,%s,%s"%(lat,lon,label.encode('utf8'),color)
        return self
        


        
